<include file="public/header" />
<include file="public/left" />
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>线路列表</h3>
                <h5>(共{}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline" action="" method="get">
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" class="qsbox" name="keyword" placeholder="可搜索地址关键字" value="{$keyword?$keyword:'';}">
                        <input  class="btn"type="submit" value="搜索">
                    </div>
                </div>
            </form>
        </div>

        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th class="sign" axis="col0">
                            <div style="width: 24px;"><i class="ico-check"></i></div>
                        </th>
                        <th align="left" abbr="ac_id" axis="col4" class="">
                            <div style="text-align: left; width: 100px;" class="">线路编号</div></th>
                        <th align="left" abbr="ac_id" axis="col4" class="">
                            <div style="text-align: left; width: 100px;" class="">线路</div></th>
                        <th align="center" axis="col1" class="handle">
                            <div style="text-align: center; width: 250px;">操作</div>
                        </th>
                        <!--<th style="width:100%" axis="col7">
                            <div></div>
                        </th>-->
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton">
                    <a href="{:url('set/routeedit')}">
                        <div class="add" title="新增线路">
                            <span><i class="fa fa-plus"></i>新增线路</span>
                        </div>
                    </a>
                </div>
            </div>
            <div style="clear:both"></div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table>
                    <tbody>
                    <volist name="route" id="vo">
                        <tr>
                            <td class="sign">
                                <div style="width: 24px;"><i class="ico-check"></i></div>
                            </td>
                            <td align="left" class="">
                                <div style="text-align: left; width: 100px;">{$vo.route_sn}</div>
                            </td>
                            <td align="left" class="">
                                <div style="text-align: left; width: 500px;">{$vo.address}</div>
                            </td>
                            <td align="center" class="handle">
                                <div style="text-align: center; width: 250px;">
                                    <a href="{:url('Set/routeedit',array('id'=>$vo.id))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>修改</a>
                                    <a href="{:url('Set/routetimeedit',array('id'=>$vo.id))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>设置时间</a>
                                    <a href="{:url('Set/routedriver',array('id'=>$vo.id))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>绑定司机</a>
                                    <a class="btn green" href="{:url('Set/routedetail',array('id'=>$vo.id))}"><i class="fa fa-list-alt"></i>查看</a>
                                    <a class="btn red"  href="javascript:void(0)" data-url="{:url('Set/route_del')}" data-id="{$vo.id}" onclick="delfun(this)"><i class="fa fa-trash-o"></i>删除</a>
                                </div>
                            </td>
                            <td align="" class="" style="width: 100%;">
                                <div>&nbsp;</div>
                            </td>
                        </tr>
                    </volist>

                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        {$page}
        <!--分页位置-->
    </div>
</div>
<script>
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });
        // 点击刷新数据
        $('.pReload').click(function(){
            location.href = location.href;
        });
        $(".sort").click(function(){
            $(this).hide();
            $(this).siblings("input").prop("type","number");
        });
        $(".sort_input").keydown(function(e){
            var ev = document.all ? window.event : e;
            if (ev.keyCode == 13) {
                var str = $(this);
                var id = $(this).data("id");
                var num = new Number($(this).val());
                //var num = a.toFixed(2);
                $.post("{:url('merchant/sort')}", {id: id, num: num}, function (result) {
                    if (result == 1) {
                        str.prop("type", "hidden");
                        str.val(num);
                        str.siblings("span").show();
                        str.siblings("span").html(num);
                    } else {
                        alert('系统繁忙，稍后再试');
                    }
                });

            }
        })
    });

    function delfun(obj) {
        // 删除按钮
        layer.confirm('确认删除？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: 'post',
                url: $(obj).attr('data-url'),
                data : {id:$(obj).attr('data-id')},
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    if (data == 1) {
                        $(obj).parent().parent().parent().remove();
                        layer.closeAll();
                    } else {
                        layer.alert('删除失败', {icon: 2});  //alert('删除失败');
                    }
                }
            })
        }, function () {
        });
    }
</script>
</body>
</html>
</html>